﻿using System.ComponentModel;
using SAPPDI.Entitys.Annotations;

namespace SAPPDI.Entitys
{
    public class CatalogoInfo : INotifyPropertyChanged
    {
        private int _idCatalogo;
        public int IdCatalogo
        {
            get { return this._idCatalogo; }
            set
            {
                this._idCatalogo = value;
                NotifyPropertyChanged("IdCatalogo");
            }
        }

        private string _descripcion;
        public string Descripcion
        {
            get { return this._descripcion; }
            set
            {
                this._descripcion = value;
                NotifyPropertyChanged("Descripcion");
            }
        }


        public override string ToString()
        {
            return Descripcion;
        }

        public CatalogoInfo()
        {
        }

        public CatalogoInfo(CatalogoInfo elemento)
        {
            if(elemento==null)return;
            this._descripcion = elemento.Descripcion;
            this._idCatalogo = elemento.IdCatalogo;
        }

        public override bool Equals(object obj)
        {
            if (obj == null || typeof(CatalogoInfo) != obj.GetType())
                return false;
            var elemento = (CatalogoInfo)obj;
            return this.Descripcion == elemento.Descripcion && this.IdCatalogo == elemento.IdCatalogo;
        }

        public static bool operator ==(CatalogoInfo a, CatalogoInfo b)
        {
            // If both are null, or both are same instance, return true.
            if (System.Object.ReferenceEquals(a, b))
            {
                return true;
            }

            // If one is null, but not both, return false.
            if (((object)a == null) || ((object)b == null))
            {
                return false;
            }

            // Return true if the fields match:
            return a.Descripcion == b.Descripcion && a.IdCatalogo == b.IdCatalogo;
        }

        public static bool operator !=(CatalogoInfo a, CatalogoInfo b)
        {
            return !(a == b);
        }

        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        protected virtual void NotifyPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
